//
//  StatusCellBottomView.swift
//  Weibo
//
//  Created by 付启刚 on 15/12/21.
//  Copyright © 2015年 faq. All rights reserved.
//

import UIKit
import SnapKit
class  StatusCellBottomView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
  @objc private func commentBtnDidClick() {
    let temp=TempViewController()
    self.navController()?.pushViewController(temp, animated: true)
    }
    private func setupUI(){
        addSubview(retweetedBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        //设置约束
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.left.top.bottom.equalTo(self)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            //1.三等分视图的第一步 两边的视图 首先 要贴边对齐
            
            make.right.equalTo(self.snp_right)
            
            //2.三等分视图的第一步 所有的视图的宽度相等
            make.width.equalTo(commentBtn.snp_width)
            make.top.bottom.equalTo(self)
        }
        
        let sepView1 = sepView()
        
        let sepView2 = sepView()
        
        let w: CGFloat = 0.5
        let scale = 0.4
        //添加分割线
        addSubview(sepView1)
        addSubview(sepView2)
        
        //设置分割线的约束
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
            commentBtn.addTarget(self, action: "commentBtnDidClick", forControlEvents: .TouchUpInside)
        }
    }
    //生成分割视图
    private func sepView() -> UIView {
        let v = UIView()
        //设置背景颜色
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }

    // MARK:懒加载所有的子视图
    
    //转发的按钮
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", backImageName: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    //评论的按钮
    private lazy var commentBtn: UIButton = UIButton(title: "评论", backImageName: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    //转发的按钮
    private lazy var likeBtn: UIButton = UIButton(title: "点赞", backImageName: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")
}
